View Javadoc
1   package edu.jiangxin.apktoolbox.swing.extend.listener;
2   
3   import edu.jiangxin.apktoolbox.swing.extend.plugin.ChangeMenuPreparePluginController;
4   import edu.jiangxin.apktoolbox.swing.extend.plugin.IPlugin;
5   import edu.jiangxin.apktoolbox.swing.extend.plugin.IPreparePluginCallback;
6   import edu.jiangxin.apktoolbox.utils.Utils;
7   
8   import java.io.File;
9   
10  public abstract class ChangeMenuToPluginListener implements IPlugin, ChangeMenuListener {
11  
12      @Override
13      public boolean isNeedPreChangeMenu() {
14          return true;
15      }
16  
17      @Override
18      public void onPreChangeMenu(IPreChangeMenuCallBack callBack) {
19          preparePlugin(new ChangeMenuPreparePluginController(getPluginFilename(), isPluginNeedUnzip(), callBack));
20      }
21  
22      @Override
23      public void onChangeMenu() {
24          String cmd = getPluginStartupCmd();
25          Utils.unBlockedExecutor(cmd);
26      }
27  
28      @Override
29      public void preparePlugin(IPreparePluginCallback callBack) {
30          callBack.onPrepareStarted();
31      }
32  
33      @Override
34      public boolean isPluginNeedUnzip() {
35          return false;
36      }
37  
38      @Override
39      public String getPluginStartupCmd() {
40          String jarPath = Utils.getPluginDirPath() + File.separator + getPluginFilename();
41          return "java -Duser.language=en -Dfile.encoding=UTF8 -jar " + jarPath;
42      }
43  }